using System.Collections.Generic;
using System;

namespace Commons.Models.Settings.Matchers.Operators
{
	[Serializable]
	public class OperatorType
	{
		protected static Dictionary<string, OperatorType> register = new Dictionary<string, OperatorType>();

		public string Name { get; private set; }

		protected OperatorType(string name)
		{
			this.Name = name;

			register.Add(name, this);
		}

		public static OperatorType GetByName(string name)
		{
			return register.ContainsKey(name) ? register[name] : null;
		}

		public override string ToString()
		{
			return Name;
		}

		public static OperatorType Eq = new OperatorType("eq"); // ==
		public static OperatorType Lt = new OperatorType("lt"); // <
		public static OperatorType Gt = new OperatorType("gt"); // >
		public static OperatorType Le = new OperatorType("le"); // <=
		public static OperatorType Ge = new OperatorType("ge"); // >=
		public static OperatorType Ne = new OperatorType("ne"); // !=
	}
}

